﻿<Page 
    x:Class="PerspectiveDemo.Wpf3D.View.Square3DAnimationDemo"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:p="http://www.codeplex.com/perspective"
    Title="Square3D animation"
    Style="{StaticResource PageStyle}">
    <Page.Resources>
        <ResourceDictionary Source="Wpf3DResources.xaml" />
    </Page.Resources>
    <p:Workshop3D>
        <p:XyzAxis3D Length="5.0" />
        <p:Square3D 
            Material="{StaticResource GlossyMaterial}" 
            BackMaterial="{StaticResource GlossyMaterial}">
            <p:Square3D.Transform>
                <Transform3DGroup>
                    <RotateTransform3D CenterX="0.5">
                        <RotateTransform3D.Rotation>
                            <AxisAngleRotation3D 
                                x:Name="modelRotation" 
                                Axis="0,1,0" />
                        </RotateTransform3D.Rotation>
                    </RotateTransform3D>
                    <TranslateTransform3D 
                        x:Name="squareTranslation"/>
                </Transform3DGroup>
            </p:Square3D.Transform>
        </p:Square3D>
        <p:Workshop3D.Triggers>
            <EventTrigger RoutedEvent="p:Workshop3D.Loaded">
                <EventTrigger.Actions>
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation From="0" To="10" Duration="0:0:4" 
                               Storyboard.TargetName="squareTranslation"
                               Storyboard.TargetProperty="OffsetX" RepeatBehavior="Forever"/>
                            <DoubleAnimation From="0" To="5" Duration="0:0:4" 
                               Storyboard.TargetName="squareTranslation"
                               Storyboard.TargetProperty="OffsetY" RepeatBehavior="Forever"/>
                            <DoubleAnimation From="0" To="15" Duration="0:0:4" 
                               Storyboard.TargetName="squareTranslation"
                               Storyboard.TargetProperty="OffsetZ" RepeatBehavior="Forever"/>
                            <DoubleAnimation From="0" To="360" Duration="0:0:2" 
                               Storyboard.TargetName="modelRotation"
                               Storyboard.TargetProperty="Angle" RepeatBehavior="Forever"/>
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger.Actions>
            </EventTrigger>
        </p:Workshop3D.Triggers>
    </p:Workshop3D>
</Page>
